package com.peter.aop.aopdemo.dao;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

@Getter
@NoArgsConstructor
@AllArgsConstructor
public enum OpActionEnum {

    //当出现数据类型不存在时，兜底不报错
    UNKNOWN("UNKNOWN", "未知"),

    LEADS_EXT_ADD("LEADS_ADD", "线索外部录入"),
    LEADS_ADD("LEADS_ADD", "线索录入"),
    LEADS_ENTER_UN_ALLOCATION("LEADS_ADD", "待分配线索-线索录入"),
    LEADS_ENTER_UN_FOLLOW_UP("LEADS_ADD", "待跟进线索-线索录入"),
    LEADS_REFINE("LEADS_REFINE", "订单提炼线索-线索录入"),
    LEADS_IMPORT("LEADS_IMPORT", "线索导入"),
    LEADS_ALLOCATION("LEADS_ALLOCATION", "分配线索"),
    LEADS_CNV("LEADS_CNV", "线索转化"),
    LEADS_CLOSED("LEADS_CLOSED", "线索关闭"),
    LEADS_TRANSFER("LEADS_TRANSFER", "线索流转"),
    LEADS_LOCK("LEADS_LOCK", "线索锁定"),
    LEADS_UN_LOCK("LEADS_UN_LOCK", "线索解锁"),
    LEADS_FOLLOWUP("LEADS_FOLLOWUP", "线索跟进"),
    LEADS_UPDATE("LEADS_UPDATE", "线索编辑"),
    LEADS_OPP_DELETE("LEADS_OPP_DELETE", "商机删除"),
    LEADS_OPP_ADD("LEADS_OPP_ADD", "商机新增"),
    LEADS_OPP_UPDATE("LEADS_OPP_UPDATE", "商机编辑"),
    LEADS_PUB_SEA_GET("LEADS_PUB_SEA_GET", "线索领取"),
    LEADS_TRANSFER_ON_SAME_ORG("LEADS_TRANSFER_ON_SAME_ORG", "线索移交"),
    LEADS_RELEASE("LEADS_RELEASE", "线索释放"),


    //订单相关操作记录
    ORDER_ADD("ORDER_ADD", "生成订单"),
    ORDER_DISPATCH("ORDER_DISPATCH", "订单分配"),
    ORDER_SECOND_DISPATCH("ORDER_SECOND_DISPATCH", "二次分配"),//老数据
    ORDER_TRANSFER("ORDER_TRANSFER", "订单移交"),
    ORDER_EDIT_CUSTOMER("ORDER_EDIT_CUSTOMER", "修改客户"),
    ORDER_UPDATE("ORDER_UPDATE", "修改主订单"),
    ORDER_ADD_PRODUCT("ORDER_ADD_PRODUCT", "新增商品"),
    ORDER_PRODUCT_DELETE("ORDER_PRODUCT_DELETE", "商品失效"),
    ORDER_EDIT_PRODUCT_NUM("ORDER_EDIT_PRODUCT_NUM", "修改商品数量"),
    SUB_ORDER_EDIT("SUB_ORDER_EDIT", "编辑子订单"),
    ORDER_EXTRACT_CLUE("ORDER_EXTRACT_CLUE", "关联线索"),
    ORDER_FOLLOW_RECORD("ORDER_FOLLOW_RECORD", "跟进记录"),
    ORDER_CREATE_CONTRACT("ORDER_CREATE_CONTRACT", "创建合同"),
    ORDER_REFUND("ORDER_REFUND", "退款"),
    ORDER_DELETE("ORDER_DELETE", "删除订单"),
    ORDER_RELATE_DIFF_ORDER("ORDER_RELATE_DIFF_ORDER", "关联补差订单"),//老数据
    ORDER_DISPATCH_CONTRACT("ORDER_DISPATCH_CONTRACT", "合同分发"),//老数据
    ORDER_REST_AMOUNT("ORDER_REST_AMOUNT", "生成尾款"),//老数据
    ORDER_ADD_COMPANY("ORDER_ADD_COMPANY", "新增公司"),//老数据
    ORDER_STATE_MODIFY("ORDER_STATE_MODIFY", "服务状态变更"),//老数据
    ORDER_PRODUCT_CHANGE("ORDER_PRODUCT_CHANGE", "商品变更"),//老数据
    ORDER_CONTRACT_SUBMIT("ORDER_CONTRACT_SUBMIT", "提交合同"),//老数据
    ORDER_DISPATCH_ORG("ORDER_DISPATCH_ORG", "订单分配服务商"),//老数据
    ORDER_DISPATCH_ACCOUNT("ORDER_DISPATCH_ACCOUNT", "订单分配会计"),//老数据
    ORDER_DEAL("ORDER_DEAL", "会计处理记录"),//老数据
    ORDER_CONFIRM("ORDER_CONFIRM", "用户确认"),
    ORDER_HANG_UP("ORDER_HANG_UP", "订单挂起"),
    ORDER_MIGRATION_DIFF_SUB_ORDER_REMOVE("ORDER_MIGRATION_DIFF_SUB_ORDER_REMOVE", "跨单补差"),
    ORDER_MIGRATION_DIFF_SUB_ORDER_ADD("ORDER_MIGRATION_DIFF_SUB_ORDER_ADD", "跨单补差"),


    REFUND_ORDER_APPLY("REFUND_ORDER_APPLY", "发起退款"),
    REFUND_ORDER_EDIT("REFUND_ORDER_EDIT", "编辑退款单"),
    REFUND_ORDER_CANCEL("REFUND_ORDER_CANCEL", "撤销退款单"),
    REFUND_ORDER_APPROVAL("REFUND_ORDER_APPROVAL", "完结退款单"),
    REFUND_ORDER_FOLLOWUP("REFUND_ORDER_FOLLOWUP", "编辑退款跟进备注"),

    COMPENSATE_ORDER_APPLY("COMPENSATE_ORDER_APPLY", "创建赔付单款"),
    COMPENSATE_ORDER_EDIT("COMPENSATE_ORDER_EDIT", "编辑赔付单"),
    COMPENSATE_ORDER_FOLLOWUP("COMPENSATE_ORDER_FOLLOWUP", "编辑赔付跟进备注"),

    //渠道订单
    CHANNEL_ORDER_ADD("CHANNEL_ORDER_ADD", "新增渠道订单"),
    CHANNEL_ORDER_UPDATE("CHANNEL_ORDER_ADD", "修改渠道订单"),
    CHANNEL_ORDER_CANCEL("CHANNEL_ORDER_CANCEL", "撤销渠道订单"),


    //客户中心-联系人
    CUSTOMER_COMPANY_CONTACTS_ADD("CUSTOMER_COMPANY_CONTACTS_ADD", "添加公司联系人"),
    CUSTOMER_COMPANY_CONTACTS_EDIT("CUSTOMER_COMPANY_CONTACTS_EDIT", "编辑公司联系人"),
    CUSTOMER_COMPANY_CONTACTS_DELETE("CUSTOMER_COMPANY_CONTACTS_DELETE", "删除公司联系人"),
    CUSTOMER_COMPANY_BASE_INFO_EDIT("CUSTOMER_COMPANY_BASE_INFO_EDIT", "编辑客户基本信息"),
    CUSTOMER_COMPANY_ALLOCATED_ADVISOR("CUSTOMER_COMPANY_ALLOCATED_ADVISOR", "分配客户"),

    //绑定群
    CUSTOMER_GROUP_BIND_SUB_ORDER("CUSTOMER_GROUP_BIND_SUB_ORDER", "绑定群子订单"),

    //查看密码
    LOOK_PASSWORD("LOOK_PASSWORD", "查看密码");//老数据;//老数据

    private String code;

    private String desc;


    public static OpActionEnum of(String code) {
        OpActionEnum[] values = OpActionEnum.values();
        for (OpActionEnum item : values) {
            if (item.getCode().equals(code)) {
                return item;
            }
        }
        return OpActionEnum.UNKNOWN;
    }


    public static List<String> getRefundOpActionCodes() {
        List<OpActionEnum> opActionEnumList = new ArrayList<>();
        opActionEnumList.add(REFUND_ORDER_APPLY);
        opActionEnumList.add(REFUND_ORDER_EDIT);
        opActionEnumList.add(REFUND_ORDER_CANCEL);
        opActionEnumList.add(REFUND_ORDER_APPROVAL);
        opActionEnumList.add(REFUND_ORDER_FOLLOWUP);
        return opActionEnumList.stream().map(OpActionEnum::getCode).collect(Collectors.toList());
    }

    public static List<String> getCompensateOrderOpActionCodes() {
        List<OpActionEnum> opActionEnumList = new ArrayList<>();
        opActionEnumList.add(COMPENSATE_ORDER_APPLY);
        opActionEnumList.add(COMPENSATE_ORDER_EDIT);
        opActionEnumList.add(COMPENSATE_ORDER_FOLLOWUP);
        return opActionEnumList.stream().map(OpActionEnum::getCode).collect(Collectors.toList());
    }

}
